/*
Compare differences in group-specific estimates for education level
College-Some College 
College-High School
College-No High School
No High School-High School 
No High School-Some College
High School-Some College
*/

// Make empty files for putting results in later

clear all
gen str32 vble = ""
foreach v in d_empt_tau0tau6 d_empt_tau1tau6 d_empt_pre1pre6 d_empt_pre3pre6 ///
	d_empt_tau0 d_empt_tau1 d_empt_tau2 d_empt_tau3 d_empt_tau4 ///
	d_empt_tau5 d_empt_tau6 d_empt_d_ATT  ///
	d_wgt_tau0tau6 d_wgt_tau1tau6 d_wgt_pre1pre6 d_wgt_pre3pre6 ///
	d_wgt_tau0 d_wgt_tau1 d_wgt_tau2 d_wgt_tau3 d_wgt_tau4 ///
	d_wgt_tau5 d_wgt_tau6 d_wgt_d_ATT  ///
	d_empc_tau0tau6 d_empc_tau1tau6 d_empc_pre1pre6 d_empc_pre3pre6 ///
	d_empc_tau0 d_empc_tau1 d_empc_tau2 d_empc_tau3 d_empc_tau4 ///
	d_empc_tau5 d_empc_tau6 d_empc_d_ATT  ///
	d_wgc_tau0tau6 d_wgc_tau1tau6 d_wgc_pre1pre6 d_wgc_pre3pre6 ///
	d_wgc_tau0 d_wgc_tau1 d_wgc_tau2 d_wgc_tau3 d_wgc_tau4 ///
	d_wgc_tau5 d_wgc_tau6 d_wgc_d_ATT {
	gen double `v' = .
}

drop if _n>0

save "/projects/users/########/Snapshot2022/Results/col_somcol_compare.dta", replace
save "/projects/users/########/Snapshot2022/Results/col_high_compare.dta", replace
save "/projects/users/########/Snapshot2022/Results/col_nohigh_compare.dta", replace
save "/projects/users/########/Snapshot2022/Results/nohigh_high_compare.dta", replace
save "/projects/users/########/Snapshot2022/Results/nohigh_somcol_compare.dta", replace
save "/projects/users/########/Snapshot2022/Results/high_somcol_compare.dta", replace

************************************
* College-Some College Comparison
************************************

// Read and organize data from each education level

clear all
use "/projects/users/########/Snapshot2022/Results/lpdid2_strateq2_college2.dta"

keep vble b_*
rename b_emp20bscpl0 b_empt_col
rename b_emp20cbscpl0 b_empc_col
rename b_wg20bscpl0 b_wgt_col
rename b_wg20cbscpl0 b_wgc_col
gen index = _n

tempfile col_estimates
save `col_estimates'

use "/projects/users/########/Snapshot2022/Results/lpdid2_strateq2_somecoll2.dta", clear

keep vble b_*
rename b_emp20bscpl0 b_empt_somcol
rename b_emp20cbscpl0 b_empc_somcol
rename b_wg20bscpl0 b_wgt_somcol
rename b_wg20cbscpl0 b_wgc_somcol
gen index = _n

merge 1:1 index using `col_estimates'
keep if _merge==3

gen d_empt = b_empt_col - b_empt_somcol
gen d_wgt = b_wgt_col - b_wgt_somcol
gen d_empc = b_empc_col - b_empc_somcol
gen d_wgc = b_wgc_col - b_wgc_somcol

// Create tempfile to hold results of comparisons

capture postutil clear
tempfile col_somcol
postfile handle str32 vble double ///
	d_empt_tau0tau6 d_empt_tau1tau6 d_empt_pre1pre6 d_empt_pre3pre6 ///
	d_empt_tau0 d_empt_tau1 d_empt_tau2 d_empt_tau3 d_empt_tau4 ///
	d_empt_tau5 d_empt_tau6 d_empt_d_ATT  ///
	d_wgt_tau0tau6 d_wgt_tau1tau6 d_wgt_pre1pre6 d_wgt_pre3pre6 ///
	d_wgt_tau0 d_wgt_tau1 d_wgt_tau2 d_wgt_tau3 d_wgt_tau4 ///
	d_wgt_tau5 d_wgt_tau6 d_wgt_d_ATT  ///
	d_empc_tau0tau6 d_empc_tau1tau6 d_empc_pre1pre6 d_empc_pre3pre6 ///
	d_empc_tau0 d_empc_tau1 d_empc_tau2 d_empc_tau3 d_empc_tau4 ///
	d_empc_tau5 d_empc_tau6 d_empc_d_ATT  ///
	d_wgc_tau0tau6 d_wgc_tau1tau6 d_wgc_pre1pre6 d_wgc_pre3pre6 ///
	d_wgc_tau0 d_wgc_tau1 d_wgc_tau2 d_wgc_tau3 d_wgc_tau4 ///
	d_wgc_tau5 d_wgc_tau6 d_wgc_d_ATT  ///
	using `col_somcol', replace
	
// Calculate comparisons and store in a matrix

foreach var of varlist d_empt d_wgt d_empc d_wgc {
	matrix comps = J(12,4,.)
	matrix colnames comps = Num MeanDiff PctPos PctNeg
	
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6"), det
	matrix comps[1,1] = r(N)
	matrix comps[1,2] = r(mean)
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6") & `var'>0
	matrix comps[1,3] = r(N)/comps[1,1]
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6") & `var'<0
	matrix comps[1,4] = r(N)/comps[1,1]
	
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6"), det
	matrix comps[2,1] = r(N)
	matrix comps[2,2] = r(mean)
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6") & `var'>0
	matrix comps[2,3] = r(N)/comps[2,1]
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6") & `var'<0
	matrix comps[2,4] = r(N)/comps[2,1]	
	
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6"), det
	matrix comps[3,1] = r(N)
	matrix comps[3,2] = r(mean)
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6") & `var'>0
	matrix comps[3,3] = r(N)/comps[3,1]
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6") & `var'<0
	matrix comps[3,4] = r(N)/comps[3,1]

	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6"), det
	matrix comps[4,1] = r(N)
	matrix comps[4,2] = r(mean)
	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6") & `var'>0
	matrix comps[4,3] = r(N)/comps[4,1]
	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6") & `var'<0
	matrix comps[4,4] = r(N)/comps[4,1]
	
	foreach num of numlist 0/6 {
		summ `var' if inlist(vble,"tau`num'"), det
		matrix comps[5+`num',1] = r(N)
		matrix comps[5+`num',2] = r(mean)
		summ `var' if inlist(vble,"tau`num'") & `var'>0
		matrix comps[5+`num',3] = r(N)/comps[5+`num',1]
		summ `var' if inlist(vble,"tau`num'") & `var'<0
		matrix comps[5+`num',4] = r(N)/comps[5+`num',1]
	}
	
	matrix rownames comps = ///
		`var'_tau0tau6 `var'_tau1tau6 `var'_pre1pre6 `var'_pre3pre6 ///
		`var'_tau0 `var'_tau1 `var'_tau2 `var'_tau3 `var'_tau4 ///
		`var'_tau5 `var'_tau6 `var'_d_ATT 
		
	matrix col_somcol_`var' = (comps)
	matrix drop comps
}

// Export the matrix values to the temp file and save a permanent file

foreach v in Num MeanDiff PctPos PctNeg {
	post handle ("`v'") ///
	(col_somcol_d_empt["d_empt_tau0tau6", "`v'"]) ///
	(col_somcol_d_empt["d_empt_tau1tau6", "`v'"]) ///
	(col_somcol_d_empt["d_empt_pre1pre6", "`v'"]) ///
	(col_somcol_d_empt["d_empt_pre3pre6", "`v'"]) ///
	(col_somcol_d_empt["d_empt_tau0", "`v'"]) (col_somcol_d_empt["d_empt_tau1", "`v'"]) ///
	(col_somcol_d_empt["d_empt_tau2", "`v'"]) (col_somcol_d_empt["d_empt_tau3", "`v'"]) ///
	(col_somcol_d_empt["d_empt_tau4", "`v'"]) (col_somcol_d_empt["d_empt_tau5", "`v'"]) ///
	(col_somcol_d_empt["d_empt_tau6", "`v'"]) (col_somcol_d_empt["d_empt_d_ATT", "`v'"]) ///
	(col_somcol_d_wgt["d_wgt_tau0tau6", "`v'"]) ///
	(col_somcol_d_wgt["d_wgt_tau1tau6", "`v'"]) ///
	(col_somcol_d_wgt["d_wgt_pre1pre6", "`v'"]) ///
	(col_somcol_d_wgt["d_wgt_pre3pre6", "`v'"]) ///
	(col_somcol_d_wgt["d_wgt_tau0", "`v'"]) (col_somcol_d_wgt["d_wgt_tau1", "`v'"]) ///
	(col_somcol_d_wgt["d_wgt_tau2", "`v'"]) (col_somcol_d_wgt["d_wgt_tau3", "`v'"]) ///
	(col_somcol_d_wgt["d_wgt_tau4", "`v'"]) (col_somcol_d_wgt["d_wgt_tau5", "`v'"]) ///
	(col_somcol_d_wgt["d_wgt_tau6", "`v'"]) (col_somcol_d_wgt["d_wgt_d_ATT", "`v'"]) ///
	(col_somcol_d_empc["d_empc_tau0tau6", "`v'"]) ///
	(col_somcol_d_empc["d_empc_tau1tau6", "`v'"]) ///
	(col_somcol_d_empc["d_empc_pre1pre6", "`v'"]) ///
	(col_somcol_d_empc["d_empc_pre3pre6", "`v'"]) ///
	(col_somcol_d_empc["d_empc_tau0", "`v'"]) (col_somcol_d_empc["d_empc_tau1", "`v'"]) ///
	(col_somcol_d_empc["d_empc_tau2", "`v'"]) (col_somcol_d_empc["d_empc_tau3", "`v'"]) ///
	(col_somcol_d_empc["d_empc_tau4", "`v'"]) (col_somcol_d_empc["d_empc_tau5", "`v'"]) ///
	(col_somcol_d_empc["d_empc_tau6", "`v'"]) (col_somcol_d_empc["d_empc_d_ATT", "`v'"]) ///
	(col_somcol_d_wgc["d_wgc_tau0tau6", "`v'"]) ///
	(col_somcol_d_wgc["d_wgc_tau1tau6", "`v'"]) ///
	(col_somcol_d_wgc["d_wgc_pre1pre6", "`v'"]) ///
	(col_somcol_d_wgc["d_wgc_pre3pre6", "`v'"]) ///
	(col_somcol_d_wgc["d_wgc_tau0", "`v'"]) (col_somcol_d_wgc["d_wgc_tau1", "`v'"]) ///
	(col_somcol_d_wgc["d_wgc_tau2", "`v'"]) (col_somcol_d_wgc["d_wgc_tau3", "`v'"]) ///
	(col_somcol_d_wgc["d_wgc_tau4", "`v'"]) (col_somcol_d_wgc["d_wgc_tau5", "`v'"]) ///
	(col_somcol_d_wgc["d_wgc_tau6", "`v'"]) (col_somcol_d_wgc["d_wgc_d_ATT", "`v'"]) 
}

postclose handle
preserve
use "/projects/users/########/Snapshot2022/Results/col_somcol_compare.dta", clear
append using `col_somcol'
save "/projects/users/########/Snapshot2022/Results/col_somcol_compare.dta", replace
restore

************************************
* College-High School Comparison
************************************

// Read and organize data from each education level

clear all
use "/projects/users/########/Snapshot2022/Results/lpdid2_strateq2_college2.dta"

keep vble b_*
rename b_emp20bscpl0 b_empt_col
rename b_emp20cbscpl0 b_empc_col
rename b_wg20bscpl0 b_wgt_col
rename b_wg20cbscpl0 b_wgc_col
gen index = _n

tempfile col_estimates
save `col_estimates'

use "/projects/users/########/Snapshot2022/Results/lpdid2_strateq2_highsch2.dta", clear

keep vble b_*
rename b_emp20bscpl0 b_empt_high
rename b_emp20cbscpl0 b_empc_high
rename b_wg20bscpl0 b_wgt_high
rename b_wg20cbscpl0 b_wgc_high
gen index = _n

merge 1:1 index using `col_estimates'
keep if _merge==3

gen d_empt = b_empt_col - b_empt_high
gen d_wgt = b_wgt_col - b_wgt_high
gen d_empc = b_empc_col - b_empc_high
gen d_wgc = b_wgc_col - b_wgc_high

// Create tempfile to hold results of comparisons

capture postutil clear
tempfile col_high 
postfile handle str32 vble double ///
	d_empt_tau0tau6 d_empt_tau1tau6 d_empt_pre1pre6 d_empt_pre3pre6 ///
	d_empt_tau0 d_empt_tau1 d_empt_tau2 d_empt_tau3 d_empt_tau4 ///
	d_empt_tau5 d_empt_tau6 d_empt_d_ATT  ///
	d_wgt_tau0tau6 d_wgt_tau1tau6 d_wgt_pre1pre6 d_wgt_pre3pre6 ///
	d_wgt_tau0 d_wgt_tau1 d_wgt_tau2 d_wgt_tau3 d_wgt_tau4 ///
	d_wgt_tau5 d_wgt_tau6 d_wgt_d_ATT  ///
	d_empc_tau0tau6 d_empc_tau1tau6 d_empc_pre1pre6 d_empc_pre3pre6 ///
	d_empc_tau0 d_empc_tau1 d_empc_tau2 d_empc_tau3 d_empc_tau4 ///
	d_empc_tau5 d_empc_tau6 d_empc_d_ATT  ///
	d_wgc_tau0tau6 d_wgc_tau1tau6 d_wgc_pre1pre6 d_wgc_pre3pre6 ///
	d_wgc_tau0 d_wgc_tau1 d_wgc_tau2 d_wgc_tau3 d_wgc_tau4 ///
	d_wgc_tau5 d_wgc_tau6 d_wgc_d_ATT  ///
	using `col_high', replace
	
// Calculate comparisons and store in a matrix

foreach var of varlist d_empt d_wgt d_empc d_wgc {
	matrix comps = J(12,4,.)
	matrix colnames comps = Num MeanDiff PctPos PctNeg
	
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6"), det
	matrix comps[1,1] = r(N)
	matrix comps[1,2] = r(mean)
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6") & `var'>0
	matrix comps[1,3] = r(N)/comps[1,1]
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6") & `var'<0
	matrix comps[1,4] = r(N)/comps[1,1]
	
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6"), det
	matrix comps[2,1] = r(N)
	matrix comps[2,2] = r(mean)
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6") & `var'>0
	matrix comps[2,3] = r(N)/comps[2,1]
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6") & `var'<0
	matrix comps[2,4] = r(N)/comps[2,1]	
	
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6"), det
	matrix comps[3,1] = r(N)
	matrix comps[3,2] = r(mean)
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6") & `var'>0
	matrix comps[3,3] = r(N)/comps[3,1]
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6") & `var'<0
	matrix comps[3,4] = r(N)/comps[3,1]

	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6"), det
	matrix comps[4,1] = r(N)
	matrix comps[4,2] = r(mean)
	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6") & `var'>0
	matrix comps[4,3] = r(N)/comps[4,1]
	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6") & `var'<0
	matrix comps[4,4] = r(N)/comps[4,1]
	
	foreach num of numlist 0/6 {
		summ `var' if inlist(vble,"tau`num'"), det
		matrix comps[5+`num',1] = r(N)
		matrix comps[5+`num',2] = r(mean)
		summ `var' if inlist(vble,"tau`num'") & `var'>0
		matrix comps[5+`num',3] = r(N)/comps[5+`num',1]
		summ `var' if inlist(vble,"tau`num'") & `var'<0
		matrix comps[5+`num',4] = r(N)/comps[5+`num',1]
	}
	
	matrix rownames comps = ///
		`var'_tau0tau6 `var'_tau1tau6 `var'_pre1pre6 `var'_pre3pre6 ///
		`var'_tau0 `var'_tau1 `var'_tau2 `var'_tau3 `var'_tau4 ///
		`var'_tau5 `var'_tau6 `var'_d_ATT 
		
	matrix colhigh_`var' = (comps)
	matrix drop comps
}

// Export the matrix values to the temp file and save a permanent file

foreach v in Num MeanDiff PctPos PctNeg {
	post handle ("`v'") ///
	(colhigh_d_empt["d_empt_tau0tau6", "`v'"]) ///
	(colhigh_d_empt["d_empt_tau1tau6", "`v'"]) ///
	(colhigh_d_empt["d_empt_pre1pre6", "`v'"]) ///
	(colhigh_d_empt["d_empt_pre3pre6", "`v'"]) ///
	(colhigh_d_empt["d_empt_tau0", "`v'"]) (colhigh_d_empt["d_empt_tau1", "`v'"]) ///
	(colhigh_d_empt["d_empt_tau2", "`v'"]) (colhigh_d_empt["d_empt_tau3", "`v'"]) ///
	(colhigh_d_empt["d_empt_tau4", "`v'"]) (colhigh_d_empt["d_empt_tau5", "`v'"]) ///
	(colhigh_d_empt["d_empt_tau6", "`v'"]) (colhigh_d_empt["d_empt_d_ATT", "`v'"]) ///
	(colhigh_d_wgt["d_wgt_tau0tau6", "`v'"]) ///
	(colhigh_d_wgt["d_wgt_tau1tau6", "`v'"]) ///
	(colhigh_d_wgt["d_wgt_pre1pre6", "`v'"]) ///
	(colhigh_d_wgt["d_wgt_pre3pre6", "`v'"]) ///
	(colhigh_d_wgt["d_wgt_tau0", "`v'"]) (colhigh_d_wgt["d_wgt_tau1", "`v'"]) ///
	(colhigh_d_wgt["d_wgt_tau2", "`v'"]) (colhigh_d_wgt["d_wgt_tau3", "`v'"]) ///
	(colhigh_d_wgt["d_wgt_tau4", "`v'"]) (colhigh_d_wgt["d_wgt_tau5", "`v'"]) ///
	(colhigh_d_wgt["d_wgt_tau6", "`v'"]) (colhigh_d_wgt["d_wgt_d_ATT", "`v'"]) ///
	(colhigh_d_empc["d_empc_tau0tau6", "`v'"]) ///
	(colhigh_d_empc["d_empc_tau1tau6", "`v'"]) ///
	(colhigh_d_empc["d_empc_pre1pre6", "`v'"]) ///
	(colhigh_d_empc["d_empc_pre3pre6", "`v'"]) ///
	(colhigh_d_empc["d_empc_tau0", "`v'"]) (colhigh_d_empc["d_empc_tau1", "`v'"]) ///
	(colhigh_d_empc["d_empc_tau2", "`v'"]) (colhigh_d_empc["d_empc_tau3", "`v'"]) ///
	(colhigh_d_empc["d_empc_tau4", "`v'"]) (colhigh_d_empc["d_empc_tau5", "`v'"]) ///
	(colhigh_d_empc["d_empc_tau6", "`v'"]) (colhigh_d_empc["d_empc_d_ATT", "`v'"]) ///
	(colhigh_d_wgc["d_wgc_tau0tau6", "`v'"]) ///
	(colhigh_d_wgc["d_wgc_tau1tau6", "`v'"]) ///
	(colhigh_d_wgc["d_wgc_pre1pre6", "`v'"]) ///
	(colhigh_d_wgc["d_wgc_pre3pre6", "`v'"]) ///
	(colhigh_d_wgc["d_wgc_tau0", "`v'"]) (colhigh_d_wgc["d_wgc_tau1", "`v'"]) ///
	(colhigh_d_wgc["d_wgc_tau2", "`v'"]) (colhigh_d_wgc["d_wgc_tau3", "`v'"]) ///
	(colhigh_d_wgc["d_wgc_tau4", "`v'"]) (colhigh_d_wgc["d_wgc_tau5", "`v'"]) ///
	(colhigh_d_wgc["d_wgc_tau6", "`v'"]) (colhigh_d_wgc["d_wgc_d_ATT", "`v'"]) 
}

postclose handle
preserve
use "/projects/users/########/Snapshot2022/Results/col_high_compare.dta", clear
append using `col_high'
save "/projects/users/########/Snapshot2022/Results/col_high_compare.dta", replace
restore

************************************
* College-No High School Comparison
************************************

// Read and organize data from each education level

clear all
use "/projects/users/########/Snapshot2022/Results/lpdid2_strateq2_college2.dta"

keep vble b_*
rename b_emp20bscpl0 b_empt_col
rename b_emp20cbscpl0 b_empc_col
rename b_wg20bscpl0 b_wgt_col
rename b_wg20cbscpl0 b_wgc_col
gen index = _n

tempfile col_estimates
save `col_estimates'

use "/projects/users/########/Snapshot2022/Results/lpdid2_strateq2_nohigh2.dta", clear

keep vble b_*
rename b_emp20bscpl0 b_empt_nohigh
rename b_emp20cbscpl0 b_empc_nohigh
rename b_wg20bscpl0 b_wgt_nohigh
rename b_wg20cbscpl0 b_wgc_nohigh
gen index = _n

merge 1:1 index using `col_estimates'
keep if _merge==3

gen d_empt = b_empt_col - b_empt_nohigh
gen d_wgt = b_wgt_col - b_wgt_nohigh
gen d_empc = b_empc_col - b_empc_nohigh
gen d_wgc = b_wgc_col - b_wgc_nohigh

// Create tempfile to hold results of comparisons

capture postutil clear
tempfile col_nohigh
postfile handle str32 vble double ///
	d_empt_tau0tau6 d_empt_tau1tau6 d_empt_pre1pre6 d_empt_pre3pre6 ///
	d_empt_tau0 d_empt_tau1 d_empt_tau2 d_empt_tau3 d_empt_tau4 ///
	d_empt_tau5 d_empt_tau6 d_empt_d_ATT  ///
	d_wgt_tau0tau6 d_wgt_tau1tau6 d_wgt_pre1pre6 d_wgt_pre3pre6 ///
	d_wgt_tau0 d_wgt_tau1 d_wgt_tau2 d_wgt_tau3 d_wgt_tau4 ///
	d_wgt_tau5 d_wgt_tau6 d_wgt_d_ATT  ///
	d_empc_tau0tau6 d_empc_tau1tau6 d_empc_pre1pre6 d_empc_pre3pre6 ///
	d_empc_tau0 d_empc_tau1 d_empc_tau2 d_empc_tau3 d_empc_tau4 ///
	d_empc_tau5 d_empc_tau6 d_empc_d_ATT  ///
	d_wgc_tau0tau6 d_wgc_tau1tau6 d_wgc_pre1pre6 d_wgc_pre3pre6 ///
	d_wgc_tau0 d_wgc_tau1 d_wgc_tau2 d_wgc_tau3 d_wgc_tau4 ///
	d_wgc_tau5 d_wgc_tau6 d_wgc_d_ATT  ///
	using `col_nohigh', replace
	
// Calculate comparisons and store in a matrix

foreach var of varlist d_empt d_wgt d_empc d_wgc {
	matrix comps = J(12,4,.)
	matrix colnames comps = Num MeanDiff PctPos PctNeg
	
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6"), det
	matrix comps[1,1] = r(N)
	matrix comps[1,2] = r(mean)
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6") & `var'>0
	matrix comps[1,3] = r(N)/comps[1,1]
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6") & `var'<0
	matrix comps[1,4] = r(N)/comps[1,1]
	
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6"), det
	matrix comps[2,1] = r(N)
	matrix comps[2,2] = r(mean)
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6") & `var'>0
	matrix comps[2,3] = r(N)/comps[2,1]
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6") & `var'<0
	matrix comps[2,4] = r(N)/comps[2,1]	
	
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6"), det
	matrix comps[3,1] = r(N)
	matrix comps[3,2] = r(mean)
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6") & `var'>0
	matrix comps[3,3] = r(N)/comps[3,1]
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6") & `var'<0
	matrix comps[3,4] = r(N)/comps[3,1]

	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6"), det
	matrix comps[4,1] = r(N)
	matrix comps[4,2] = r(mean)
	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6") & `var'>0
	matrix comps[4,3] = r(N)/comps[4,1]
	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6") & `var'<0
	matrix comps[4,4] = r(N)/comps[4,1]
	
	foreach num of numlist 0/6 {
		summ `var' if inlist(vble,"tau`num'"), det
		matrix comps[5+`num',1] = r(N)
		matrix comps[5+`num',2] = r(mean)
		summ `var' if inlist(vble,"tau`num'") & `var'>0
		matrix comps[5+`num',3] = r(N)/comps[5+`num',1]
		summ `var' if inlist(vble,"tau`num'") & `var'<0
		matrix comps[5+`num',4] = r(N)/comps[5+`num',1]
	}
	
	matrix rownames comps = ///
		`var'_tau0tau6 `var'_tau1tau6 `var'_pre1pre6 `var'_pre3pre6 ///
		`var'_tau0 `var'_tau1 `var'_tau2 `var'_tau3 `var'_tau4 ///
		`var'_tau5 `var'_tau6 `var'_d_ATT 
		
	matrix colnohigh_`var' = (comps)
	matrix drop comps
}

// Export the matrix values to the temp file and save a permanent file

foreach v in Num MeanDiff PctPos PctNeg {
	post handle ("`v'") ///
	(colnohigh_d_empt["d_empt_tau0tau6", "`v'"]) ///
	(colnohigh_d_empt["d_empt_tau1tau6", "`v'"]) ///
	(colnohigh_d_empt["d_empt_pre1pre6", "`v'"]) ///
	(colnohigh_d_empt["d_empt_pre3pre6", "`v'"]) ///
	(colnohigh_d_empt["d_empt_tau0", "`v'"]) (colnohigh_d_empt["d_empt_tau1", "`v'"]) ///
	(colnohigh_d_empt["d_empt_tau2", "`v'"]) (colnohigh_d_empt["d_empt_tau3", "`v'"]) ///
	(colnohigh_d_empt["d_empt_tau4", "`v'"]) (colnohigh_d_empt["d_empt_tau5", "`v'"]) ///
	(colnohigh_d_empt["d_empt_tau6", "`v'"]) (colnohigh_d_empt["d_empt_d_ATT", "`v'"]) ///
	(colnohigh_d_wgt["d_wgt_tau0tau6", "`v'"]) ///
	(colnohigh_d_wgt["d_wgt_tau1tau6", "`v'"]) ///
	(colnohigh_d_wgt["d_wgt_pre1pre6", "`v'"]) ///
	(colnohigh_d_wgt["d_wgt_pre3pre6", "`v'"]) ///
	(colnohigh_d_wgt["d_wgt_tau0", "`v'"]) (colnohigh_d_wgt["d_wgt_tau1", "`v'"]) ///
	(colnohigh_d_wgt["d_wgt_tau2", "`v'"]) (colnohigh_d_wgt["d_wgt_tau3", "`v'"]) ///
	(colnohigh_d_wgt["d_wgt_tau4", "`v'"]) (colnohigh_d_wgt["d_wgt_tau5", "`v'"]) ///
	(colnohigh_d_wgt["d_wgt_tau6", "`v'"]) (colnohigh_d_wgt["d_wgt_d_ATT", "`v'"]) ///
	(colnohigh_d_empc["d_empc_tau0tau6", "`v'"]) ///
	(colnohigh_d_empc["d_empc_tau1tau6", "`v'"]) ///
	(colnohigh_d_empc["d_empc_pre1pre6", "`v'"]) ///
	(colnohigh_d_empc["d_empc_pre3pre6", "`v'"]) ///
	(colnohigh_d_empc["d_empc_tau0", "`v'"]) (colnohigh_d_empc["d_empc_tau1", "`v'"]) ///
	(colnohigh_d_empc["d_empc_tau2", "`v'"]) (colnohigh_d_empc["d_empc_tau3", "`v'"]) ///
	(colnohigh_d_empc["d_empc_tau4", "`v'"]) (colnohigh_d_empc["d_empc_tau5", "`v'"]) ///
	(colnohigh_d_empc["d_empc_tau6", "`v'"]) (colnohigh_d_empc["d_empc_d_ATT", "`v'"]) ///
	(colnohigh_d_wgc["d_wgc_tau0tau6", "`v'"]) ///
	(colnohigh_d_wgc["d_wgc_tau1tau6", "`v'"]) ///
	(colnohigh_d_wgc["d_wgc_pre1pre6", "`v'"]) ///
	(colnohigh_d_wgc["d_wgc_pre3pre6", "`v'"]) ///
	(colnohigh_d_wgc["d_wgc_tau0", "`v'"]) (colnohigh_d_wgc["d_wgc_tau1", "`v'"]) ///
	(colnohigh_d_wgc["d_wgc_tau2", "`v'"]) (colnohigh_d_wgc["d_wgc_tau3", "`v'"]) ///
	(colnohigh_d_wgc["d_wgc_tau4", "`v'"]) (colnohigh_d_wgc["d_wgc_tau5", "`v'"]) ///
	(colnohigh_d_wgc["d_wgc_tau6", "`v'"]) (colnohigh_d_wgc["d_wgc_d_ATT", "`v'"]) 
}

postclose handle
preserve
use "/projects/users/########/Snapshot2022/Results/col_nohigh_compare.dta", clear
append using `col_nohigh'
save "/projects/users/########/Snapshot2022/Results/col_nohigh_compare.dta", replace
restore

************************************
* No High School-High School Comparison
************************************

// Read and organize data from each education level

clear all
use "/projects/users/########/Snapshot2022/Results/lpdid2_strateq2_nohigh2.dta"

keep vble b_*
rename b_emp20bscpl0 b_empt_nohigh
rename b_emp20cbscpl0 b_empc_nohigh
rename b_wg20bscpl0 b_wgt_nohigh
rename b_wg20cbscpl0 b_wgc_nohigh
gen index = _n

tempfile nohigh_estimates
save `nohigh_estimates'

use "/projects/users/########/Snapshot2022/Results/lpdid2_strateq2_highsch2.dta", clear

keep vble b_*
rename b_emp20bscpl0 b_empt_high
rename b_emp20cbscpl0 b_empc_high
rename b_wg20bscpl0 b_wgt_high
rename b_wg20cbscpl0 b_wgc_high
gen index = _n

merge 1:1 index using `nohigh_estimates'
keep if _merge==3

gen d_empt = b_empt_nohigh - b_empt_high
gen d_wgt = b_wgt_nohigh - b_wgt_high
gen d_empc = b_empc_nohigh - b_empc_high
gen d_wgc = b_wgc_nohigh - b_wgc_high

// Create tempfile to hold results of comparisons

capture postutil clear
tempfile nohigh_high
postfile handle str32 vble double ///
	d_empt_tau0tau6 d_empt_tau1tau6 d_empt_pre1pre6 d_empt_pre3pre6 ///
	d_empt_tau0 d_empt_tau1 d_empt_tau2 d_empt_tau3 d_empt_tau4 ///
	d_empt_tau5 d_empt_tau6 d_empt_d_ATT  ///
	d_wgt_tau0tau6 d_wgt_tau1tau6 d_wgt_pre1pre6 d_wgt_pre3pre6 ///
	d_wgt_tau0 d_wgt_tau1 d_wgt_tau2 d_wgt_tau3 d_wgt_tau4 ///
	d_wgt_tau5 d_wgt_tau6 d_wgt_d_ATT  ///
	d_empc_tau0tau6 d_empc_tau1tau6 d_empc_pre1pre6 d_empc_pre3pre6 ///
	d_empc_tau0 d_empc_tau1 d_empc_tau2 d_empc_tau3 d_empc_tau4 ///
	d_empc_tau5 d_empc_tau6 d_empc_d_ATT  ///
	d_wgc_tau0tau6 d_wgc_tau1tau6 d_wgc_pre1pre6 d_wgc_pre3pre6 ///
	d_wgc_tau0 d_wgc_tau1 d_wgc_tau2 d_wgc_tau3 d_wgc_tau4 ///
	d_wgc_tau5 d_wgc_tau6 d_wgc_d_ATT  ///
	using `nohigh_high', replace
	
// Calculate comparisons and store in a matrix

foreach var of varlist d_empt d_wgt d_empc d_wgc {
	matrix comps = J(12,4,.)
	matrix colnames comps = Num MeanDiff PctPos PctNeg
	
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6"), det
	matrix comps[1,1] = r(N)
	matrix comps[1,2] = r(mean)
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6") & `var'>0
	matrix comps[1,3] = r(N)/comps[1,1]
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6") & `var'<0
	matrix comps[1,4] = r(N)/comps[1,1]
	
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6"), det
	matrix comps[2,1] = r(N)
	matrix comps[2,2] = r(mean)
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6") & `var'>0
	matrix comps[2,3] = r(N)/comps[2,1]
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6") & `var'<0
	matrix comps[2,4] = r(N)/comps[2,1]	
	
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6"), det
	matrix comps[3,1] = r(N)
	matrix comps[3,2] = r(mean)
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6") & `var'>0
	matrix comps[3,3] = r(N)/comps[3,1]
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6") & `var'<0
	matrix comps[3,4] = r(N)/comps[3,1]

	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6"), det
	matrix comps[4,1] = r(N)
	matrix comps[4,2] = r(mean)
	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6") & `var'>0
	matrix comps[4,3] = r(N)/comps[4,1]
	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6") & `var'<0
	matrix comps[4,4] = r(N)/comps[4,1]
	
	foreach num of numlist 0/6 {
		summ `var' if inlist(vble,"tau`num'"), det
		matrix comps[5+`num',1] = r(N)
		matrix comps[5+`num',2] = r(mean)
		summ `var' if inlist(vble,"tau`num'") & `var'>0
		matrix comps[5+`num',3] = r(N)/comps[5+`num',1]
		summ `var' if inlist(vble,"tau`num'") & `var'<0
		matrix comps[5+`num',4] = r(N)/comps[5+`num',1]
	}
	
	matrix rownames comps = ///
		`var'_tau0tau6 `var'_tau1tau6 `var'_pre1pre6 `var'_pre3pre6 ///
		`var'_tau0 `var'_tau1 `var'_tau2 `var'_tau3 `var'_tau4 ///
		`var'_tau5 `var'_tau6 `var'_d_ATT 
		
	matrix nohighhigh_`var' = (comps)
	matrix drop comps
}

// Export the matrix values to the temp file and save a permanent file

foreach v in Num MeanDiff PctPos PctNeg {
	post handle ("`v'") ///
	(nohighhigh_d_empt["d_empt_tau0tau6", "`v'"]) ///
	(nohighhigh_d_empt["d_empt_tau1tau6", "`v'"]) ///
	(nohighhigh_d_empt["d_empt_pre1pre6", "`v'"]) ///
	(nohighhigh_d_empt["d_empt_pre3pre6", "`v'"]) ///
	(nohighhigh_d_empt["d_empt_tau0", "`v'"]) (nohighhigh_d_empt["d_empt_tau1", "`v'"]) ///
	(nohighhigh_d_empt["d_empt_tau2", "`v'"]) (nohighhigh_d_empt["d_empt_tau3", "`v'"]) ///
	(nohighhigh_d_empt["d_empt_tau4", "`v'"]) (nohighhigh_d_empt["d_empt_tau5", "`v'"]) ///
	(nohighhigh_d_empt["d_empt_tau6", "`v'"]) (nohighhigh_d_empt["d_empt_d_ATT", "`v'"]) ///
	(nohighhigh_d_wgt["d_wgt_tau0tau6", "`v'"]) ///
	(nohighhigh_d_wgt["d_wgt_tau1tau6", "`v'"]) ///
	(nohighhigh_d_wgt["d_wgt_pre1pre6", "`v'"]) ///
	(nohighhigh_d_wgt["d_wgt_pre3pre6", "`v'"]) ///
	(nohighhigh_d_wgt["d_wgt_tau0", "`v'"]) (nohighhigh_d_wgt["d_wgt_tau1", "`v'"]) ///
	(nohighhigh_d_wgt["d_wgt_tau2", "`v'"]) (nohighhigh_d_wgt["d_wgt_tau3", "`v'"]) ///
	(nohighhigh_d_wgt["d_wgt_tau4", "`v'"]) (nohighhigh_d_wgt["d_wgt_tau5", "`v'"]) ///
	(nohighhigh_d_wgt["d_wgt_tau6", "`v'"]) (nohighhigh_d_wgt["d_wgt_d_ATT", "`v'"]) ///
	(nohighhigh_d_empc["d_empc_tau0tau6", "`v'"]) ///
	(nohighhigh_d_empc["d_empc_tau1tau6", "`v'"]) ///
	(nohighhigh_d_empc["d_empc_pre1pre6", "`v'"]) ///
	(nohighhigh_d_empc["d_empc_pre3pre6", "`v'"]) ///
	(nohighhigh_d_empc["d_empc_tau0", "`v'"]) (nohighhigh_d_empc["d_empc_tau1", "`v'"]) ///
	(nohighhigh_d_empc["d_empc_tau2", "`v'"]) (nohighhigh_d_empc["d_empc_tau3", "`v'"]) ///
	(nohighhigh_d_empc["d_empc_tau4", "`v'"]) (nohighhigh_d_empc["d_empc_tau5", "`v'"]) ///
	(nohighhigh_d_empc["d_empc_tau6", "`v'"]) (nohighhigh_d_empc["d_empc_d_ATT", "`v'"]) ///
	(nohighhigh_d_wgc["d_wgc_tau0tau6", "`v'"]) ///
	(nohighhigh_d_wgc["d_wgc_tau1tau6", "`v'"]) ///
	(nohighhigh_d_wgc["d_wgc_pre1pre6", "`v'"]) ///
	(nohighhigh_d_wgc["d_wgc_pre3pre6", "`v'"]) ///
	(nohighhigh_d_wgc["d_wgc_tau0", "`v'"]) (nohighhigh_d_wgc["d_wgc_tau1", "`v'"]) ///
	(nohighhigh_d_wgc["d_wgc_tau2", "`v'"]) (nohighhigh_d_wgc["d_wgc_tau3", "`v'"]) ///
	(nohighhigh_d_wgc["d_wgc_tau4", "`v'"]) (nohighhigh_d_wgc["d_wgc_tau5", "`v'"]) ///
	(nohighhigh_d_wgc["d_wgc_tau6", "`v'"]) (nohighhigh_d_wgc["d_wgc_d_ATT", "`v'"]) 
}

postclose handle
preserve
use "/projects/users/########/Snapshot2022/Results/nohigh_high_compare.dta", clear
append using `nohigh_high'
save "/projects/users/########/Snapshot2022/Results/nohigh_high_compare.dta", replace
restore

************************************
* No High School-Some College Comparison
************************************

// Read and organize data from each education level

clear all
use "/projects/users/########/Snapshot2022/Results/lpdid2_strateq2_nohigh2.dta"

keep vble b_*
rename b_emp20bscpl0 b_empt_nohigh
rename b_emp20cbscpl0 b_empc_nohigh
rename b_wg20bscpl0 b_wgt_nohigh
rename b_wg20cbscpl0 b_wgc_nohigh
gen index = _n

tempfile nohigh_estimates
save `nohigh_estimates'

use "/projects/users/########/Snapshot2022/Results/lpdid2_strateq2_somecoll2.dta", clear

keep vble b_*
rename b_emp20bscpl0 b_empt_somcol
rename b_emp20cbscpl0 b_empc_somcol
rename b_wg20bscpl0 b_wgt_somcol
rename b_wg20cbscpl0 b_wgc_somcol
gen index = _n

merge 1:1 index using `nohigh_estimates'
keep if _merge==3

gen d_empt = b_empt_nohigh - b_empt_somcol
gen d_wgt = b_wgt_nohigh - b_wgt_somcol
gen d_empc = b_empc_nohigh - b_empc_somcol
gen d_wgc = b_wgc_nohigh - b_wgc_somcol

// Create tempfile to hold results of comparisons

capture postutil clear
tempfile nohigh_somcol 
postfile handle str32 vble double ///
	d_empt_tau0tau6 d_empt_tau1tau6 d_empt_pre1pre6 d_empt_pre3pre6 ///
	d_empt_tau0 d_empt_tau1 d_empt_tau2 d_empt_tau3 d_empt_tau4 ///
	d_empt_tau5 d_empt_tau6 d_empt_d_ATT  ///
	d_wgt_tau0tau6 d_wgt_tau1tau6 d_wgt_pre1pre6 d_wgt_pre3pre6 ///
	d_wgt_tau0 d_wgt_tau1 d_wgt_tau2 d_wgt_tau3 d_wgt_tau4 ///
	d_wgt_tau5 d_wgt_tau6 d_wgt_d_ATT  ///
	d_empc_tau0tau6 d_empc_tau1tau6 d_empc_pre1pre6 d_empc_pre3pre6 ///
	d_empc_tau0 d_empc_tau1 d_empc_tau2 d_empc_tau3 d_empc_tau4 ///
	d_empc_tau5 d_empc_tau6 d_empc_d_ATT  ///
	d_wgc_tau0tau6 d_wgc_tau1tau6 d_wgc_pre1pre6 d_wgc_pre3pre6 ///
	d_wgc_tau0 d_wgc_tau1 d_wgc_tau2 d_wgc_tau3 d_wgc_tau4 ///
	d_wgc_tau5 d_wgc_tau6 d_wgc_d_ATT  ///
	using `nohigh_somcol', replace
	
// Calculate comparisons and store in a matrix

foreach var of varlist d_empt d_wgt d_empc d_wgc {
	matrix comps = J(12,4,.)
	matrix colnames comps = Num MeanDiff PctPos PctNeg
	
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6"), det
	matrix comps[1,1] = r(N)
	matrix comps[1,2] = r(mean)
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6") & `var'>0
	matrix comps[1,3] = r(N)/comps[1,1]
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6") & `var'<0
	matrix comps[1,4] = r(N)/comps[1,1]
	
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6"), det
	matrix comps[2,1] = r(N)
	matrix comps[2,2] = r(mean)
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6") & `var'>0
	matrix comps[2,3] = r(N)/comps[2,1]
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6") & `var'<0
	matrix comps[2,4] = r(N)/comps[2,1]	
	
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6"), det
	matrix comps[3,1] = r(N)
	matrix comps[3,2] = r(mean)
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6") & `var'>0
	matrix comps[3,3] = r(N)/comps[3,1]
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6") & `var'<0
	matrix comps[3,4] = r(N)/comps[3,1]

	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6"), det
	matrix comps[4,1] = r(N)
	matrix comps[4,2] = r(mean)
	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6") & `var'>0
	matrix comps[4,3] = r(N)/comps[4,1]
	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6") & `var'<0
	matrix comps[4,4] = r(N)/comps[4,1]
	
	foreach num of numlist 0/6 {
		summ `var' if inlist(vble,"tau`num'"), det
		matrix comps[5+`num',1] = r(N)
		matrix comps[5+`num',2] = r(mean)
		summ `var' if inlist(vble,"tau`num'") & `var'>0
		matrix comps[5+`num',3] = r(N)/comps[5+`num',1]
		summ `var' if inlist(vble,"tau`num'") & `var'<0
		matrix comps[5+`num',4] = r(N)/comps[5+`num',1]
	}
	
	matrix rownames comps = ///
		`var'_tau0tau6 `var'_tau1tau6 `var'_pre1pre6 `var'_pre3pre6 ///
		`var'_tau0 `var'_tau1 `var'_tau2 `var'_tau3 `var'_tau4 ///
		`var'_tau5 `var'_tau6 `var'_d_ATT 
		
	matrix nohighsomcol_`var' = (comps)
	matrix drop comps
}

// Export the matrix values to the temp file and save a permanent file

foreach v in Num MeanDiff PctPos PctNeg {
	post handle ("`v'") ///
	(nohighsomcol_d_empt["d_empt_tau0tau6", "`v'"]) ///
	(nohighsomcol_d_empt["d_empt_tau1tau6", "`v'"]) ///
	(nohighsomcol_d_empt["d_empt_pre1pre6", "`v'"]) ///
	(nohighsomcol_d_empt["d_empt_pre3pre6", "`v'"]) ///
	(nohighsomcol_d_empt["d_empt_tau0", "`v'"]) (nohighsomcol_d_empt["d_empt_tau1", "`v'"]) ///
	(nohighsomcol_d_empt["d_empt_tau2", "`v'"]) (nohighsomcol_d_empt["d_empt_tau3", "`v'"]) ///
	(nohighsomcol_d_empt["d_empt_tau4", "`v'"]) (nohighsomcol_d_empt["d_empt_tau5", "`v'"]) ///
	(nohighsomcol_d_empt["d_empt_tau6", "`v'"]) (nohighsomcol_d_empt["d_empt_d_ATT", "`v'"]) ///
	(nohighsomcol_d_wgt["d_wgt_tau0tau6", "`v'"]) ///
	(nohighsomcol_d_wgt["d_wgt_tau1tau6", "`v'"]) ///
	(nohighsomcol_d_wgt["d_wgt_pre1pre6", "`v'"]) ///
	(nohighsomcol_d_wgt["d_wgt_pre3pre6", "`v'"]) ///
	(nohighsomcol_d_wgt["d_wgt_tau0", "`v'"]) (nohighsomcol_d_wgt["d_wgt_tau1", "`v'"]) ///
	(nohighsomcol_d_wgt["d_wgt_tau2", "`v'"]) (nohighsomcol_d_wgt["d_wgt_tau3", "`v'"]) ///
	(nohighsomcol_d_wgt["d_wgt_tau4", "`v'"]) (nohighsomcol_d_wgt["d_wgt_tau5", "`v'"]) ///
	(nohighsomcol_d_wgt["d_wgt_tau6", "`v'"]) (nohighsomcol_d_wgt["d_wgt_d_ATT", "`v'"]) ///
	(nohighsomcol_d_empc["d_empc_tau0tau6", "`v'"]) ///
	(nohighsomcol_d_empc["d_empc_tau1tau6", "`v'"]) ///
	(nohighsomcol_d_empc["d_empc_pre1pre6", "`v'"]) ///
	(nohighsomcol_d_empc["d_empc_pre3pre6", "`v'"]) ///
	(nohighsomcol_d_empc["d_empc_tau0", "`v'"]) (nohighsomcol_d_empc["d_empc_tau1", "`v'"]) ///
	(nohighsomcol_d_empc["d_empc_tau2", "`v'"]) (nohighsomcol_d_empc["d_empc_tau3", "`v'"]) ///
	(nohighsomcol_d_empc["d_empc_tau4", "`v'"]) (nohighsomcol_d_empc["d_empc_tau5", "`v'"]) ///
	(nohighsomcol_d_empc["d_empc_tau6", "`v'"]) (nohighsomcol_d_empc["d_empc_d_ATT", "`v'"]) ///
	(nohighsomcol_d_wgc["d_wgc_tau0tau6", "`v'"]) ///
	(nohighsomcol_d_wgc["d_wgc_tau1tau6", "`v'"]) ///
	(nohighsomcol_d_wgc["d_wgc_pre1pre6", "`v'"]) ///
	(nohighsomcol_d_wgc["d_wgc_pre3pre6", "`v'"]) ///
	(nohighsomcol_d_wgc["d_wgc_tau0", "`v'"]) (nohighsomcol_d_wgc["d_wgc_tau1", "`v'"]) ///
	(nohighsomcol_d_wgc["d_wgc_tau2", "`v'"]) (nohighsomcol_d_wgc["d_wgc_tau3", "`v'"]) ///
	(nohighsomcol_d_wgc["d_wgc_tau4", "`v'"]) (nohighsomcol_d_wgc["d_wgc_tau5", "`v'"]) ///
	(nohighsomcol_d_wgc["d_wgc_tau6", "`v'"]) (nohighsomcol_d_wgc["d_wgc_d_ATT", "`v'"]) 
}

postclose handle
preserve
use "/projects/users/########/Snapshot2022/Results/nohigh_somcol_compare.dta", clear
append using `nohigh_somcol'
save "/projects/users/########/Snapshot2022/Results/nohigh_somcol_compare.dta", replace
restore

************************************
* High School-Some College Comparison
************************************

// Read and organize data from each education level

clear all
use "/projects/users/########/Snapshot2022/Results/lpdid2_strateq2_highsch2.dta"

keep vble b_*
rename b_emp20bscpl0 b_empt_high
rename b_emp20cbscpl0 b_empc_high
rename b_wg20bscpl0 b_wgt_high
rename b_wg20cbscpl0 b_wgc_high
gen index = _n

tempfile high_estimates
save `high_estimates'

use "/projects/users/########/Snapshot2022/Results/lpdid2_strateq2_somecoll2.dta", clear

keep vble b_*
rename b_emp20bscpl0 b_empt_somcol
rename b_emp20cbscpl0 b_empc_somcol
rename b_wg20bscpl0 b_wgt_somcol
rename b_wg20cbscpl0 b_wgc_somcol
gen index = _n

merge 1:1 index using `high_estimates'
keep if _merge==3

gen d_empt = b_empt_high - b_empt_somcol
gen d_wgt = b_wgt_high - b_wgt_somcol
gen d_empc = b_empc_high - b_empc_somcol
gen d_wgc = b_wgc_high - b_wgc_somcol

// Create tempfile to hold results of comparisons

capture postutil clear
tempfile high_somcol
postfile handle str32 vble double ///
	d_empt_tau0tau6 d_empt_tau1tau6 d_empt_pre1pre6 d_empt_pre3pre6 ///
	d_empt_tau0 d_empt_tau1 d_empt_tau2 d_empt_tau3 d_empt_tau4 ///
	d_empt_tau5 d_empt_tau6 d_empt_d_ATT  ///
	d_wgt_tau0tau6 d_wgt_tau1tau6 d_wgt_pre1pre6 d_wgt_pre3pre6 ///
	d_wgt_tau0 d_wgt_tau1 d_wgt_tau2 d_wgt_tau3 d_wgt_tau4 ///
	d_wgt_tau5 d_wgt_tau6 d_wgt_d_ATT  ///
	d_empc_tau0tau6 d_empc_tau1tau6 d_empc_pre1pre6 d_empc_pre3pre6 ///
	d_empc_tau0 d_empc_tau1 d_empc_tau2 d_empc_tau3 d_empc_tau4 ///
	d_empc_tau5 d_empc_tau6 d_empc_d_ATT  ///
	d_wgc_tau0tau6 d_wgc_tau1tau6 d_wgc_pre1pre6 d_wgc_pre3pre6 ///
	d_wgc_tau0 d_wgc_tau1 d_wgc_tau2 d_wgc_tau3 d_wgc_tau4 ///
	d_wgc_tau5 d_wgc_tau6 d_wgc_d_ATT  ///
	using `high_somcol', replace
	
// Calculate comparisons and store in a matrix

foreach var of varlist d_empt d_wgt d_empc d_wgc {
	matrix comps = J(12,4,.)
	matrix colnames comps = Num MeanDiff PctPos PctNeg
	
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6"), det
	matrix comps[1,1] = r(N)
	matrix comps[1,2] = r(mean)
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6") & `var'>0
	matrix comps[1,3] = r(N)/comps[1,1]
	summ `var' if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6") & `var'<0
	matrix comps[1,4] = r(N)/comps[1,1]
	
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6"), det
	matrix comps[2,1] = r(N)
	matrix comps[2,2] = r(mean)
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6") & `var'>0
	matrix comps[2,3] = r(N)/comps[2,1]
	summ `var' if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6") & `var'<0
	matrix comps[2,4] = r(N)/comps[2,1]	
	
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6"), det
	matrix comps[3,1] = r(N)
	matrix comps[3,2] = r(mean)
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6") & `var'>0
	matrix comps[3,3] = r(N)/comps[3,1]
	summ `var' if inlist(vble,"pre1","pre3","pre4","pre5","pre6") & `var'<0
	matrix comps[3,4] = r(N)/comps[3,1]

	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6"), det
	matrix comps[4,1] = r(N)
	matrix comps[4,2] = r(mean)
	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6") & `var'>0
	matrix comps[4,3] = r(N)/comps[4,1]
	summ `var' if inlist(vble,"pre3","pre4","pre5","pre6") & `var'<0
	matrix comps[4,4] = r(N)/comps[4,1]
	
	foreach num of numlist 0/6 {
		summ `var' if inlist(vble,"tau`num'"), det
		matrix comps[5+`num',1] = r(N)
		matrix comps[5+`num',2] = r(mean)
		summ `var' if inlist(vble,"tau`num'") & `var'>0
		matrix comps[5+`num',3] = r(N)/comps[5+`num',1]
		summ `var' if inlist(vble,"tau`num'") & `var'<0
		matrix comps[5+`num',4] = r(N)/comps[5+`num',1]
	}
	
	matrix rownames comps = ///
		`var'_tau0tau6 `var'_tau1tau6 `var'_pre1pre6 `var'_pre3pre6 ///
		`var'_tau0 `var'_tau1 `var'_tau2 `var'_tau3 `var'_tau4 ///
		`var'_tau5 `var'_tau6 `var'_d_ATT 
		
	matrix highsomcol_`var' = (comps)
	matrix drop comps
}

// Export the matrix values to the temp file and save a permanent file

foreach v in Num MeanDiff PctPos PctNeg {
	post handle ("`v'") ///
	(highsomcol_d_empt["d_empt_tau0tau6", "`v'"]) ///
	(highsomcol_d_empt["d_empt_tau1tau6", "`v'"]) ///
	(highsomcol_d_empt["d_empt_pre1pre6", "`v'"]) ///
	(highsomcol_d_empt["d_empt_pre3pre6", "`v'"]) ///
	(highsomcol_d_empt["d_empt_tau0", "`v'"]) (highsomcol_d_empt["d_empt_tau1", "`v'"]) ///
	(highsomcol_d_empt["d_empt_tau2", "`v'"]) (highsomcol_d_empt["d_empt_tau3", "`v'"]) ///
	(highsomcol_d_empt["d_empt_tau4", "`v'"]) (highsomcol_d_empt["d_empt_tau5", "`v'"]) ///
	(highsomcol_d_empt["d_empt_tau6", "`v'"]) (highsomcol_d_empt["d_empt_d_ATT", "`v'"]) ///
	(highsomcol_d_wgt["d_wgt_tau0tau6", "`v'"]) ///
	(highsomcol_d_wgt["d_wgt_tau1tau6", "`v'"]) ///
	(highsomcol_d_wgt["d_wgt_pre1pre6", "`v'"]) ///
	(highsomcol_d_wgt["d_wgt_pre3pre6", "`v'"]) ///
	(highsomcol_d_wgt["d_wgt_tau0", "`v'"]) (highsomcol_d_wgt["d_wgt_tau1", "`v'"]) ///
	(highsomcol_d_wgt["d_wgt_tau2", "`v'"]) (highsomcol_d_wgt["d_wgt_tau3", "`v'"]) ///
	(highsomcol_d_wgt["d_wgt_tau4", "`v'"]) (highsomcol_d_wgt["d_wgt_tau5", "`v'"]) ///
	(highsomcol_d_wgt["d_wgt_tau6", "`v'"]) (highsomcol_d_wgt["d_wgt_d_ATT", "`v'"]) ///
	(highsomcol_d_empc["d_empc_tau0tau6", "`v'"]) ///
	(highsomcol_d_empc["d_empc_tau1tau6", "`v'"]) ///
	(highsomcol_d_empc["d_empc_pre1pre6", "`v'"]) ///
	(highsomcol_d_empc["d_empc_pre3pre6", "`v'"]) ///
	(highsomcol_d_empc["d_empc_tau0", "`v'"]) (highsomcol_d_empc["d_empc_tau1", "`v'"]) ///
	(highsomcol_d_empc["d_empc_tau2", "`v'"]) (highsomcol_d_empc["d_empc_tau3", "`v'"]) ///
	(highsomcol_d_empc["d_empc_tau4", "`v'"]) (highsomcol_d_empc["d_empc_tau5", "`v'"]) ///
	(highsomcol_d_empc["d_empc_tau6", "`v'"]) (highsomcol_d_empc["d_empc_d_ATT", "`v'"]) ///
	(highsomcol_d_wgc["d_wgc_tau0tau6", "`v'"]) ///
	(highsomcol_d_wgc["d_wgc_tau1tau6", "`v'"]) ///
	(highsomcol_d_wgc["d_wgc_pre1pre6", "`v'"]) ///
	(highsomcol_d_wgc["d_wgc_pre3pre6", "`v'"]) ///
	(highsomcol_d_wgc["d_wgc_tau0", "`v'"]) (highsomcol_d_wgc["d_wgc_tau1", "`v'"]) ///
	(highsomcol_d_wgc["d_wgc_tau2", "`v'"]) (highsomcol_d_wgc["d_wgc_tau3", "`v'"]) ///
	(highsomcol_d_wgc["d_wgc_tau4", "`v'"]) (highsomcol_d_wgc["d_wgc_tau5", "`v'"]) ///
	(highsomcol_d_wgc["d_wgc_tau6", "`v'"]) (highsomcol_d_wgc["d_wgc_d_ATT", "`v'"]) 
}

postclose handle
preserve
use "/projects/users/########/Snapshot2022/Results/high_somcol_compare.dta", clear
append using `high_somcol'
save "/projects/users/########/Snapshot2022/Results/high_somcol_compare.dta", replace
restore

/*
Histograms of differences

// Compare binary treatment on employment
hist d_empt if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6")
hist d_empt if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6")

hist d_empt if inlist(vble,"pre1","pre3","pre4","pre5","pre6")
hist d_empt if inlist(vble,"pre3","pre4","pre5","pre6")

hist d_empt if inlist(vble,"tau0")
hist d_empt if inlist(vble,"tau1")
hist d_empt if inlist(vble,"tau2")
hist d_empt if inlist(vble,"tau3")
hist d_empt if inlist(vble,"tau4")
hist d_empt if inlist(vble,"tau5")
hist d_empt if inlist(vble,"tau6")

// Compare binary treatment on earnings
hist d_wgt if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6")
hist d_wgt if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6")

hist d_wgt if inlist(vble,"pre1","pre3","pre4","pre5","pre6")
hist d_wgt if inlist(vble,"pre3","pre4","pre5","pre6")

hist d_wgt if inlist(vble,"tau0")
hist d_wgt if inlist(vble,"tau1")
hist d_wgt if inlist(vble,"tau2")
hist d_wgt if inlist(vble,"tau3")
hist d_wgt if inlist(vble,"tau4")
hist d_wgt if inlist(vble,"tau5")
hist d_wgt if inlist(vble,"tau6")

// Compare continuous treatment on employment
hist d_empc if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6")
hist d_empc if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6")

hist d_empc if inlist(vble,"pre1","pre3","pre4","pre5","pre6")
hist d_empc if inlist(vble,"pre3","pre4","pre5","pre6")

hist d_empc if inlist(vble,"tau0")
hist d_empc if inlist(vble,"tau1")
hist d_empc if inlist(vble,"tau2")
hist d_empc if inlist(vble,"tau3")
hist d_empc if inlist(vble,"tau4")
hist d_empc if inlist(vble,"tau5")
hist d_empc if inlist(vble,"tau6")

// Compare continuous treatment on earnings
hist d_wgc if inlist(vble,"tau0","tau1","tau2","tau3","tau4","tau5","tau6")
hist d_wgc if inlist(vble,"tau1","tau2","tau3","tau4","tau5","tau6")

hist d_wgc if inlist(vble,"pre1","pre3","pre4","pre5","pre6")
hist d_wgc if inlist(vble,"pre3","pre4","pre5","pre6")

hist d_wgc if inlist(vble,"tau0")
hist d_wgc if inlist(vble,"tau1")
hist d_wgc if inlist(vble,"tau2")
hist d_wgc if inlist(vble,"tau3")
hist d_wgc if inlist(vble,"tau4")
hist d_wgc if inlist(vble,"tau5")
hist d_wgc if inlist(vble,"tau6")
*/
